﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MDA
{
    /// <summary>
    /// 当用window.open()打开一个窗体时．用于打开的参数．
    /// </summary>
    public class WinOpenArgs
    {
        /// <summary>
        /// 将打开的目标页面．
        /// </summary>
        public string Url;
        /// <summary>
        /// 页面打开的目标框架．
        /// </summary>
        public Target UTarget = Target._blank;
        /// <summary>
        /// 页面的打开样式．　
        /// </summary>
        public WOFeature Features = new WOFeature();
        /// <summary>
        /// 是否在历史列表中替换当前的文档．　
        /// Optional. When the sURL is loaded into the same window, 
        /// this Boolean parameter specifies whether the sURL creates a new entry or replaces the current entry in the window's history list. 
        /// true-sURL replaces the current document in the history list 
        /// false-sURL creates a new entry in the history list.  
        /// </summary>
        public bool Replace;

        public WinOpenArgs()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
    }

    /// <summary>
    /// 用于定义window.open()页面显示的效果．
    /// </summary>
    public class WOFeature
    {
        /// <summary>
        /// Specifies whether to display the window in theater mode and show the channel band. 
        /// The default is no.
        /// </summary>
        public WOFeatureValues channelmode = WOFeatureValues.no;
        public string Channelmode
        {
            get
            {
                if (channelmode == WOFeatureValues.one)
                    return "1";
                else if (channelmode == WOFeatureValues.zero)
                    return "0";
                else return channelmode.ToString();
            }
            set
            {
                channelmode = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to add directory buttons.
        /// The default is yes.
        /// </summary>
        public WOFeatureValues directories = WOFeatureValues.yes;
        public string Directories
        {
            get
            {
                if (directories == WOFeatureValues.one)
                    return "1";
                else if (directories == WOFeatureValues.zero)
                    return "0";
                else return directories.ToString();
            }
            set
            {
                directories = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display the browser in full-screen mode. 
        /// The default is no. Use full-screen mode carefully. 
        /// Because this mode hides the browser's title bar and menus, 
        /// you should always provide a button or other visual clue to help the user close the window.
        /// ALT+F4 closes the new window.
        /// A window in full-screen mode must also be in theater mode (channelmode). 
        /// </summary>
        public WOFeatureValues fullscreen = WOFeatureValues.no;
        public string Fullscreen
        {
            get
            {
                if (fullscreen == WOFeatureValues.one)
                    return "1";
                else if (fullscreen == WOFeatureValues.zero)
                    return "0";
                else return fullscreen.ToString();
            }
            set
            {
                fullscreen = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display the input field for entering URLs directly into the browser.
        /// The default is yes.
        /// </summary>
        public WOFeatureValues location = WOFeatureValues.yes;
        public string Location
        {
            get
            {
                if (location == WOFeatureValues.one)
                    return "1";
                else if (location == WOFeatureValues.zero)
                    return "0";
                else return location.ToString();
            }
            set
            {
                location = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display the menu bar.
        /// The default is yes.
        /// </summary>
        public WOFeatureValues menubar = WOFeatureValues.yes;
        public string Menubar
        {
            get
            {
                if (menubar == WOFeatureValues.one)
                    return "1";
                else if (menubar == WOFeatureValues.zero)
                    return "0";
                else return menubar.ToString();
            }
            set
            {
                menubar = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display resize handles at the corners of the window. 
        /// The default is yes.
        /// </summary>
        public WOFeatureValues resizable = WOFeatureValues.yes;
        public string Resizable
        {
            get
            {
                if (resizable == WOFeatureValues.one)
                    return "1";
                else if (resizable == WOFeatureValues.zero)
                    return "0";
                else return resizable.ToString();
            }
            set
            {
                resizable = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display horizontal and vertical scroll bars. 
        /// The default is yes.
        /// </summary>
        public WOFeatureValues scrollbars = WOFeatureValues.yes;
        public string Scrollbars
        {
            get
            {
                if (scrollbars == WOFeatureValues.one)
                    return "1";
                else if (scrollbars == WOFeatureValues.zero)
                    return "0";
                else return scrollbars.ToString();
            }
            set
            {
                scrollbars = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to add a status bar at the bottom of the window. 
        /// The default is yes.
        /// </summary>
        public WOFeatureValues status = WOFeatureValues.yes;
        public string Status
        {
            get
            {
                if (status == WOFeatureValues.one)
                    return "1";
                else if (status == WOFeatureValues.zero)
                    return "0";
                else return status.ToString();
            }
            set
            {
                status = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display a title bar for the window. 
        /// This parameter is ignored unless the calling application is an HTML Application or a trusted dialog box.
        /// The default is yes.
        /// </summary>
        public WOFeatureValues titlebar = WOFeatureValues.yes;
        public string Titlebar
        {
            get
            {
                if (titlebar == WOFeatureValues.one)
                    return "1";
                else if (titlebar == WOFeatureValues.zero)
                    return "0";
                else return titlebar.ToString();
            }
            set
            {
                titlebar = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// Specifies whether to display the browser toolbar, 
        /// making buttons such as Back, Forward, and Stop available. 
        /// The default is yes.
        /// </summary>
        public WOFeatureValues toolbar = WOFeatureValues.yes;
        public string Toolbar
        {
            get
            {
                if (toolbar == WOFeatureValues.one)
                    return "1";
                else if (toolbar == WOFeatureValues.zero)
                    return "0";
                else return toolbar.ToString();
            }
            set
            {
                toolbar = (WOFeatureValues)Enum.Parse(typeof(WOFeatureValues), value);
            }
        }
        /// <summary>
        /// 对话框的上方到屏幕上边的距离。


        /// </summary>
        public int top;
        /// <summary>
        /// 对话框的高度。最小值为：100
        /// </summary>
        public int width;
        /// <summary>
        /// 对话框高度。最小值为：100
        /// </summary>
        public int height;
        /// <summary>
        /// 对话框左侧到屏幕左边的距离。


        /// </summary>
        public int left;
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (top != 0)
                sb.Append("top=" + top.ToString() + ",");
            if (width != 0)
                sb.Append("width=" + width.ToString() + ",");
            if (height != 0)
                sb.Append("height=" + height.ToString() + ",");
            if (left != 0)
                sb.Append("left=" + left.ToString() + ",");
            if (channelmode != WOFeatureValues.no)
                sb.Append("channelmode=" + Channelmode + ",");
            if (directories != WOFeatureValues.yes)
                sb.Append("directories=" + Directories + ",");
            if (fullscreen != WOFeatureValues.no)
                sb.Append("fullscreen=" + Fullscreen + ",");
            if (location != WOFeatureValues.yes)
                sb.Append("location=" + Location + ",");
            if (menubar != WOFeatureValues.yes)
                sb.Append("menubar=" + Menubar + ",");
            if (resizable != WOFeatureValues.yes)
                sb.Append("resizable=" + Resizable + ",");
            if (scrollbars != WOFeatureValues.yes)
                sb.Append("scrollbars=" + Scrollbars + ",");
            if (status != WOFeatureValues.yes)
                sb.Append("status=" + Status + ",");
            if (titlebar != WOFeatureValues.yes)
                sb.Append("titlebar=" + Titlebar + ",");
            if (toolbar != WOFeatureValues.yes)
                sb.Append("toolbar=" + Toolbar);
            return sb.ToString();
        }


    }

    /// <summary>
    /// 页面打开的框架目标


    /// </summary>
    public enum Target
    {
        /// <summary>
        /// 新的浏览器窗口


        /// </summary>
        _blank,
        /// <summary>
        /// The sURL is loaded into the HTML content area of the Media Bar. 
        /// Available in Internet Explorer 6 or later.
        /// </summary>
        _media,
        /// <summary>
        /// 父级窗口
        /// </summary>
        _parent,
        /// <summary>
        /// Available in Internet Explorer 5 and later.
        /// The sURL is opened in the browser's search pane.
        /// </summary>
        _search,
        /// <summary>
        /// 当前窗口
        /// </summary>
        _self,
        /// <summary>
        /// 顶级窗口，即当前浏览器。


        /// </summary>
        _top
    }

    /// <summary>
    /// 用于页面效果项。


    /// </summary>
    public enum WOFeatureValues
    {
        /// <summary>
        /// 启用当前的效果项。


        /// </summary>
        yes,
        /// <summary>
        /// 不用当前的效果项。


        /// </summary>
        no,
        one,
        zero
    }
}